package com.mypring.controller;

import com.mypring.entity.Distance_AvgPrice;
import com.mypring.entity.Fang;
import com.mypring.entity.Layout_AvgPrice;
import com.mypring.mapper.FangMapper;
import com.mypring.service.FangService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class FangController {

    @Autowired
    private FangService fangService;

    @GetMapping("/echart")
    @ResponseBody
    public List<Fang> PieRegion(){
        List<Fang> fangs = fangService.findRegion();
//        System.out.println(fangs);
        return fangs;
    }


//    不同距离范围内房源的平均价格
    @GetMapping("/distance_avg_price")
    @ResponseBody
    public List<Distance_AvgPrice> Distance_AvgPrice() {
        List<Distance_AvgPrice> distanceAvgPrices =fangService.findDistance_AvgPrice();
//        System.out.println(distanceAvgPrices);
        return distanceAvgPrices;

    }

    @GetMapping("/layout_avg_price")
    @ResponseBody
    public List<Layout_AvgPrice> Average_neaPrice(){
        List<Layout_AvgPrice> layoutAvgPrices = fangService.findLayout_AvgPrice();
        System.out.println(layoutAvgPrices);
        return layoutAvgPrices;
    }

}